//
//  LogCatManager.h
//  LogCat
//
//  Created by 清风徐来 on 2022/12/28.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <LogCat/LogCatLocalModel.h>

NS_ASSUME_NONNULL_BEGIN

@protocol LogCatManagerDelegate <NSObject>

@required
- (void)web_setPushModeForOff:(BOOL)enable;
- (void)web_destroyGeTuiSDK;

@end


/** 请求配置的Block */
typedef void (^LogCatConfigBlock)(LogCatLocalModel * configModel);
/** 初始化SDK结果Block */
typedef void (^LogCatResultBlock)(BOOL showOldPage, NSString *msg);

@interface LogCatManager : NSObject

/// 获取 LogCatManager 管理器实例
+ (LogCatManager*)shared;

//MARK: - 启动SDK配置

/// 启动SDK
/// - Parameters:
///   - config: 配置Model
///   - resultBlock: 注册回调
- (void)startWith:(LogCatConfigBlock)config 
         delegate:(_Nullable id<LogCatManagerDelegate>)deleage
           result:(_Nullable LogCatResultBlock)resultBlock;

/// 启动SDK
/// - Parameters:
///   - configModel: 配置model
///   - resultBlock: 注册回调
- (void)startWithConfigModel:(LogCatLocalModel *)configModel 
                    delegate:(_Nullable id<LogCatManagerDelegate>)deleage
                      result:(_Nullable LogCatResultBlock)resultBlock;

/// 启动SDK
/// - Parameters:
///   - appid: appid 注册时传入，不可为空
///   - appKey: appKey 注册时传入，不可为空
///   - version: version 注册时传入，不可为空
///   - validYear: validYear 注册时传入，不可为空
///   - validMonth: validMonth 注册时传入，不可为空
///   - validDay: validDay 注册时传入，不可为空
///   - scheme: scheme 注册时传入，不可为空
///   - bundleId: bundleId 注册时传入，不可为空
///   - localUrl: localUrl 本地默认加载的地址
- (void)startWithAppid:(nonnull NSString *)appid 
                appKey:(nonnull NSString *)appKey
               version:(nonnull NSString *)version
             validYear:(nonnull NSString *)validYear
            validMonth:(nonnull NSString *)validMonth
              validDay:(nonnull NSString *)validDay
                scheme:(nonnull NSString *)scheme
              bundleId:(nonnull NSString *)bundleId
              localUrl:(nonnull NSString *)localUrl
              delegate:(_Nullable id<LogCatManagerDelegate>)deleage
                result:(_Nullable LogCatResultBlock)resultBlock;

/// 刷新远端配置
/// - Parameter resultBlock: 回调
- (void)reloadRemoteConfig;


//MARK: - web的操作

/// 重新加载Web
- (void)reloadWeb;

///  清除WKWebView的缓存
- (void)removeAllWebCached;

/// 加载Web页面
/// - Parameter localUrl: 地址
- (void)loadWebPageWithUrl:(NSString *)localUrl;


//MARK: - DeviceToken的操作
/**
 * 绑定设备UUID
 * - Parameters:
 *   - uuid: uuid
 *   - successBlock: 成功回调
 */
-(void)bindDeviceId:(NSString *)uuid success:(LogCatResultBlock)successBlock;

/**
 * 绑定个推cid
 * - Parameters:
 *   - cid: cid
 */
-(void)bindGeTuiCid:(NSString *)cid;

/**
 * 获取个推cid
 */
-( NSString * _Nullable )getGeTuiCid;

/**
 * 获取注册的Scheme
 */
-(NSString *)getScheme;

/**
 * 获取设备APPID
 */
-(NSString *)getAPPID;

/**
 * 获取APPID的key
 */
-(NSString *)getAPPIDKey;

/**
 * 获取设备ID的key
 */
-(NSString *)getUUIDKey;

/**
 * 获取设备UUID
 */
-(NSString *)getDeviceUUID;

/**
 * 将某个时间转化成 时间戳
 * formatTime：时间内容（xxxx-xx-xx）
 * format：时间转换格式（yyyyMMdd HH:MM:ss）
 */
-(NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format;

/**
 * 获取当前时间的 时间戳
 */
-(NSInteger)getNowTimestamp;

@end

NS_ASSUME_NONNULL_END
